﻿@model IEnumerable<GraduateManagement.Models.users>
@using GraduateManagement.Models;
@{
    ViewBag.Title = "用户管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2 style="font-family: 微软雅黑; ">@ViewBag.Title</h2>

<p>
    @Html.ActionLink("新建用户", "Create", null, new { style = "font-family: 微软雅黑; text-decoration: none; " })
</p>
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.accountNum)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.academy)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.roleID)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.accountNum)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.name)
        </td>
        @{
            SqlDbContext db = new SqlDbContext();
            string academy = db.academy_table.Single(a => a.ID == item.academy).name;
            string role = db.role_table.Single(r => r.ID == item.roleID).name;
        }
        <td>
            @academy
        </td>
        <td>
            @role
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
            @Html.ActionLink("Details", "Details", new { id=item.ID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.ID })
        </td>
    </tr>
}

</table>
